Computer programs are usually broken into a number of modules. Each module typically contains the code for one or more procedures used in the program. Some of the modules may be provided by outside sources and be available only in object code. Some modules may contain source code that facilitates the implementation of certain classes of programs. The remaining code may be broken into a plurality of modules simply to reduce the amount of material that must be compiled or edited in any one operation.
Prior to the execution of the program, the code in the various modules must be compiled. Typically, the compiler converts each module having a source code therein into an object code module. The object code modules are then linked together to generate the final executable program. To simplify this process, many systems provide "MAKE" utilities that keep track of the modules used in a given program and generate the final executable code. The MAKE program, when invoked, checks to see which modules have been modified since the last compilation thereof and recompiles the modified source code modules prior to invoking the linker.
The speed with which a given program executes on a particular computer can be significantly increased by using various forms of code optimization. For example, variables that are used frequently throughout the program may be allocated to registers within the CPU rather than left in memory. Similarly, if a subroutine is particularly small, the optimizer may replace calls to the subroutine by inline code. Programs for providing the optimization are known to those skilled in the art. For the purposes of the present discussion, it is sufficient to note that the degree of improvement provided by the optimization procedures increases with the amount of information available to the optimization program. For example, an optimizer cannot inline code if it does not have access to the subroutine in question because the subroutine is in a module that is not available to the optimizer. As a result, it is advantageous to perform optimization across as many modules as possible.
While the division of the code into a number of modules simplifies some tasks, it limits the scope of optimization to a single module. Once the source code has been compiled to object code, many forms of optimization are no longer available. Hence, the optimizer must operate on a source level code and have as many modules available to it as possible.
One prior method for providing optimization is to compile the source code modules to an intermediate code format and then optimize all of the intermediate code modules together. The intermediate code is a machine independent code. The optimizer generates an object code file which is then linked with other object code files to generate the executable code.
While this methodology allows the user to optimize his or her code, it has the disadvantage of requiring the user to learn a new system. The intermediate code files are generated by a separate compiler. In addition, the optimizer requires the user to use a new utility that operates only on the intermediate code files. The output of this utility must then be given to the conventional linker to provide the executable code. Each new program that the user must learn places a significant burden on the user. In addition, the probability that the user will err in using the system increases as the number of steps increases.
Broadly, it is the object of the present invention to provide an improved optimizing compiler.
It is a further object of the present invention to provide a compiler architecture that is transparent to the user.
These and other objects of the present invention will become apparent to those skilled in the art from the following detailed description of the invention and the accompanying drawings.